package com.whisperarts.financer.app.utils;

import org.eclipse.jface.action.IStatusLineManager;
import org.eclipse.swt.widgets.Display;

public class StatusLineUtils {
	
	private static IStatusLineManager statusLine;
	private static Thread statusLineUpdater;
	private static String text1 = "Online", text2 = "offline";
	
	static {
		statusLineUpdater = new Thread(new Runnable() {			
			@Override
			public void run() {
				System.out.println("runniong");
				while (!statusLineUpdater.isInterrupted()) {
					try {
						setMessage(text1);
						statusLineUpdater.sleep(2000);
						setMessage(text2);
						statusLineUpdater.sleep(2000);
					} catch (InterruptedException e) {
						e.printStackTrace();
					}
				}
			}
		});		
	}
	
	
	public static void setStatusLineManager(IStatusLineManager statusLineManager) {
		statusLine = statusLineManager;
	}
	
	public static void setMessage(String text) {
		statusLine.setMessage(text);
	}
	
	public static void startUpdater(Display display, boolean start) {
		Display.getDefault().asyncExec( 
				new Runnable() {  
					@Override
					public void run() {
					
					}
				});

//		if (start) {
//			statusLineUpdater.start();
//		} else {
//			statusLineUpdater.interrupt();
//		}
	}
}
